﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Pikapika.Models;

namespace Pikapika.Areas.Admin.Controllers
{
    public class NovelVolumeController : CrudControllerBase<NovelVolume>
    {

        protected override System.Data.Objects.ObjectSet<NovelVolume> GetObjectSet(PikapikaDBEntities ctx)
        {
            return ctx.NovelVolumes;
        }

        protected override IQueryable<NovelVolume> GetObjectQuery(PikapikaDBEntities ctx)
        {
            IQueryable<NovelVolume> query = ctx.NovelVolumes.Include("Novel");
            RouteData.ProcessOptionalId("novelId", (novelId) =>
            {
                query = query.Where(n => n.NovelId == novelId);
                ViewBag.NovelId = novelId;
            });
            return query;
        }


        public ActionResult Create(int novelId)
        {
            return View(new NovelVolume() { NovelId = novelId });
        }

        [NonAction]
        public override ActionResult Create()
        {
            return base.Create();
        }
    }
}
